namespace NFTRedit
{
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;

    public class PropertiesForm : Form
    {
        private Button buttonApply;
        private Button buttonCancel;
        private Button buttonOK;
        private IContainer components;
        private NFTRedit.Font font;
        private GroupBox groupBoxDimensions;
        private bool isLoading;
        private Label label1;
        private Label labelHeight;
        private Label labelWidth;
        private NumericUpDown numericUpDownHeight;
        private NumericUpDown numericUpDownWidth;
        private MainForm parent;
        private CharacterTable table;
        private TextBox textBoxBPP;

        public PropertiesForm()
        {
            this.InitializeComponent();
        }

        private void ApplyChanges()
        {
            this.parent.ResizeTiles((byte) this.numericUpDownWidth.Value, (byte) this.numericUpDownHeight.Value);
        }

        private void ButtonApplyClick(object sender, EventArgs e)
        {
            this.ApplyChanges();
            this.buttonApply.Enabled = false;
        }

        private void ButtonCancelClick(object sender, EventArgs e)
        {
            base.Close();
        }

        private void ButtonOKClick(object sender, EventArgs e)
        {
            this.ApplyChanges();
            base.Close();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            ComponentResourceManager manager = new ComponentResourceManager(typeof(PropertiesForm));
            this.labelWidth = new Label();
            this.groupBoxDimensions = new GroupBox();
            this.textBoxBPP = new TextBox();
            this.label1 = new Label();
            this.numericUpDownHeight = new NumericUpDown();
            this.numericUpDownWidth = new NumericUpDown();
            this.labelHeight = new Label();
            this.buttonOK = new Button();
            this.buttonCancel = new Button();
            this.buttonApply = new Button();
            this.groupBoxDimensions.SuspendLayout();
            this.numericUpDownHeight.BeginInit();
            this.numericUpDownWidth.BeginInit();
            base.SuspendLayout();
            this.labelWidth.Location = new Point(6, 0x15);
            this.labelWidth.Name = "labelWidth";
            this.labelWidth.Size = new Size(0x29, 13);
            this.labelWidth.TabIndex = 1;
            this.labelWidth.Text = "Width:";
            this.groupBoxDimensions.Controls.Add(this.textBoxBPP);
            this.groupBoxDimensions.Controls.Add(this.label1);
            this.groupBoxDimensions.Controls.Add(this.numericUpDownHeight);
            this.groupBoxDimensions.Controls.Add(this.numericUpDownWidth);
            this.groupBoxDimensions.Controls.Add(this.labelHeight);
            this.groupBoxDimensions.Controls.Add(this.labelWidth);
            this.groupBoxDimensions.Location = new Point(12, 12);
            this.groupBoxDimensions.Name = "groupBoxDimensions";
            this.groupBoxDimensions.Size = new Size(0xed, 100);
            this.groupBoxDimensions.TabIndex = 2;
            this.groupBoxDimensions.TabStop = false;
            this.groupBoxDimensions.Text = "Tile Properties";
            this.textBoxBPP.Location = new Point(0x35, 70);
            this.textBoxBPP.MaxLength = 2;
            this.textBoxBPP.Name = "textBoxBPP";
            this.textBoxBPP.ReadOnly = true;
            this.textBoxBPP.Size = new Size(40, 20);
            this.textBoxBPP.TabIndex = 7;
            this.label1.Location = new Point(6, 0x49);
            this.label1.Name = "label1";
            this.label1.Size = new Size(0x29, 13);
            this.label1.TabIndex = 5;
            this.label1.Text = "BPP:";
            this.numericUpDownHeight.Location = new Point(0x35, 0x2d);
            int[] bits = new int[4];
            bits[0] = 0x80;
            this.numericUpDownHeight.Maximum = new decimal(bits);
            int[] numArray2 = new int[4];
            numArray2[0] = 2;
            this.numericUpDownHeight.Minimum = new decimal(numArray2);
            this.numericUpDownHeight.Name = "numericUpDownHeight";
            this.numericUpDownHeight.Size = new Size(40, 20);
            this.numericUpDownHeight.TabIndex = 4;
            int[] numArray3 = new int[4];
            numArray3[0] = 12;
            this.numericUpDownHeight.Value = new decimal(numArray3);
            this.numericUpDownHeight.ValueChanged += new EventHandler(this.NumericUpDownValueChanged);
            this.numericUpDownWidth.Location = new Point(0x35, 0x13);
            int[] numArray4 = new int[4];
            numArray4[0] = 0x80;
            this.numericUpDownWidth.Maximum = new decimal(numArray4);
            int[] numArray5 = new int[4];
            numArray5[0] = 2;
            this.numericUpDownWidth.Minimum = new decimal(numArray5);
            this.numericUpDownWidth.Name = "numericUpDownWidth";
            this.numericUpDownWidth.Size = new Size(40, 20);
            this.numericUpDownWidth.TabIndex = 3;
            int[] numArray6 = new int[4];
            numArray6[0] = 12;
            this.numericUpDownWidth.Value = new decimal(numArray6);
            this.numericUpDownWidth.ValueChanged += new EventHandler(this.NumericUpDownValueChanged);
            this.labelHeight.Location = new Point(6, 0x2f);
            this.labelHeight.Name = "labelHeight";
            this.labelHeight.Size = new Size(0x29, 13);
            this.labelHeight.TabIndex = 2;
            this.labelHeight.Text = "Height:";
            this.buttonOK.Location = new Point(12, 0x76);
            this.buttonOK.Name = "buttonOK";
            this.buttonOK.Size = new Size(0x4b, 0x17);
            this.buttonOK.TabIndex = 3;
            this.buttonOK.Text = "OK";
            this.buttonOK.UseVisualStyleBackColor = true;
            this.buttonOK.Click += new EventHandler(this.ButtonOKClick);
            this.buttonCancel.DialogResult = DialogResult.Cancel;
            this.buttonCancel.Location = new Point(0x5d, 0x76);
            this.buttonCancel.Name = "buttonCancel";
            this.buttonCancel.Size = new Size(0x4b, 0x17);
            this.buttonCancel.TabIndex = 4;
            this.buttonCancel.Text = "Cancel";
            this.buttonCancel.UseVisualStyleBackColor = true;
            this.buttonCancel.Click += new EventHandler(this.ButtonCancelClick);
            this.buttonApply.DialogResult = DialogResult.Cancel;
            this.buttonApply.Enabled = false;
            this.buttonApply.Location = new Point(0xae, 0x76);
            this.buttonApply.Name = "buttonApply";
            this.buttonApply.Size = new Size(0x4b, 0x17);
            this.buttonApply.TabIndex = 5;
            this.buttonApply.Text = "Apply";
            this.buttonApply.UseVisualStyleBackColor = true;
            this.buttonApply.Click += new EventHandler(this.ButtonApplyClick);
            base.AcceptButton = this.buttonOK;
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.CancelButton = this.buttonCancel;
            base.ClientSize = new Size(260, 150);
            base.Controls.Add(this.buttonApply);
            base.Controls.Add(this.buttonCancel);
            base.Controls.Add(this.buttonOK);
            base.Controls.Add(this.groupBoxDimensions);
            base.FormBorderStyle = FormBorderStyle.FixedSingle;
            base.Icon = (Icon) manager.GetObject("$this.Icon");
            base.Name = "PropertiesForm";
            this.Text = "Properties";
            this.groupBoxDimensions.ResumeLayout(false);
            this.groupBoxDimensions.PerformLayout();
            this.numericUpDownHeight.EndInit();
            this.numericUpDownWidth.EndInit();
            base.ResumeLayout(false);
        }

        private void NumericUpDownValueChanged(object sender, EventArgs e)
        {
            if (!this.isLoading)
            {
                this.buttonApply.Enabled = true;
            }
        }

        public void Show(MainForm pParent, NFTRedit.Font pFont, CharacterTable pTable)
        {
            this.parent = pParent;
            this.font = pFont;
            this.table = pTable;
            this.isLoading = true;
            this.numericUpDownWidth.Value = this.font.MaxWidth;
            this.numericUpDownHeight.Value = this.font.MaxHeight;
            this.textBoxBPP.Text = "" + this.font.BPP;
            this.isLoading = false;
            base.Show();
        }
    }
}

